﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Web;
using WebChart;
using TSharp.Core.AppBox.Perfmon;

namespace TSharp.Core.AppBox.Handlers
{
    public class PerfmonImageHandler : DynamicImageHandler
    {
        public PerfmonImageHandler(HttpContext context, string requestType, string url, string pathTranslated)
            : base(context, requestType, url, pathTranslated)
        { }

        public ChartEngine engine
        {
            get
            {
                return PerfmonUtil.ChartEngineSession;
            }
        } 
        private ChartEngine Refresh(ChartEngine engine)
        {
            PerfmonUtil.RefreshData(engine, QPerfMonFile.Instance);
            return engine;
        }


        protected override Bitmap GetBitmap(HttpContext context)
        {
            return Refresh(engine).GetBitmap();
        }
    }
}